var customerColumns = [{
    id: 'area',
    title: '区域',
    type: 'string',
    columnClass: 'text-center',
    resolution: function (value) {
        var content = '';
        if (value=="HD"){
            content ="华东";
        }else if (value=="HB"){
            content = "华北";
        }else if (value=="DB"){
            content = "东北";
        }else if (value=="HZE"){
            content = "华中二";
        }else if (value=="XN"){
            content = "西南";
        }else if (value=="HN"){
            content = "华南";
        }else if (value=="HZY"){
            content = "华中一";
        }else if (value=="GW"){
            content = "国外";
        }
        return content;
    }
    },{
            id: 'com_name',
            title: '客户名称',
            type: 'string',
            columnClass: 'text-center'
        },
    {
        id: 'com_type',
        title: '客户类型',
        type: 'string',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'industry',
        title: '行业',
        type: 'string',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'address',
        title: '地址',
        type: 'string',
        columnClass: 'text-left'
    },
    {
        id: 'telephone',
        title: '联系方式',
        type: 'string',
        width: 110,
        columnClass: 'text-center'
    },
    {
        id: 'userId',
        title: '我司负责人',
        type: 'string',
        width: 100,
        columnClass: 'text-center'
    },
    {
        id: 'createUser',
        title: '创建人',
        type: 'string',
        width: 75,
        columnClass: 'text-center'
    }, {
        id: 'operation',
        title: '操作',
        type: 'string',
        width: 300,
        columnClass: 'text-center',
        resolution: function (value, record, column, grid, dataNo, columnNo) {
            var content = '';
            content += '<button class="btn btn-xs btn-success" onclick="selsu(' + record.id + ');"><i class="icon-edit"></i>  更新客户信息</button>';
            content += '  ';
            content += '<button class="btn btn-xs btn-primary" onclick="selist(' + record.id + ');"><i class="icon-eye-open"></i>  查看联系人</button>';
            content += '  ';
            content += '<button class="btn btn-xs btn-info" onclick="selsut(' + record.id + ');"><i class="icon-plus"></i>  添加联系人</button>';
            return content;
        }
    }
];

function findCusList(CertusJsonAjax, CertusFormAjax) {
    this.search = function (code, param) {
        $("#customerContainer").html("");
        $("#customerToolBarContainer").html("");
        CertusJsonAjax.dataInit("findList", {
                "code": code,
                "param": param,
                "userId":"1"
            }, customerColumns,
            "customerContainer", "customerToolBarContainer", 20, [20, 25, 30]);
    }
    search("0", "");
    this.changeparam = function (code) {
        var html = "";
        if (code == 0) {
            //全部
            html += '<input type="text" value="" id="searchParam" style="border-bottom-right-radius: 4px;border-top-right-radius: 4px;" class="form-control" disabled/>';
            $("#paramt").html(html);
        } else if (code == 1) {
            //客户名称
            html += '<input type="text" value="" id="searchParam" class="form-control" style="border-bottom-right-radius: 4px;border-top-right-radius: 4px;" class="form-control" placeholder="客户名称"/>';
            $("#paramt").html(html);
        } else if (code == 2 || code == 3) {
            //归属人
            html += '<input type="text" value="" id="searchParam" class="form-control" style="border-bottom-right-radius: 4px;border-top-right-radius: 4px;" class="form-control" placeholder="中文名称或工号"/>';
            $("#paramt").html(html);
        }
    }
    $(".psearch").on('click', function () {
        var code = $("#searchCode").val();
        var param = $("#searchParam").val();
        search(code, param);
        // CertusFormAjax.ajax('test',{},function () {
        //
        // })
    });
}
// 编辑客户
function selsu(id) {
    window.location.href = "#/toEditCus/" + id;
};
//查看联系人
function selist(id) {
    window.location.href = "#/toFindCus/" + id;
}

function selsut(id) {
    window.location.href = "#/toAddCus/" + id;
}